package com.burry.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.util.ServletContextAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;

public class BaseAction extends ActionSupport implements ServletContextAware,
		ServletRequestAware, ServletResponseAware {

	protected ServletContext servletContext = null;
	private javax.servlet.http.HttpServletRequest request = null;
	private javax.servlet.http.HttpServletResponse response = null;

	// 当前bizFuncId
	private String currentBizFuncId = null;

	/**
	 * 由派生类在某个action确定转向某个对应其他bizFuncId的功能的时候，set forward的页面的BusiFunctionId
	 * 注意：某个action处理多个页面，所以某个action实际上可能在多个方法里调用本方法.则页面对应的标准FeFilter、
	 * FeView等对象只能指定一个
	 * 
	 * @return
	 */
	protected void setForwordBizFuncId(String currentBizFuncId) {
		// 新的bizfuncid
		this.currentBizFuncId = currentBizFuncId;
	}

	protected List getBusiFunctionId() {
		List listFuncId = new ArrayList();
		// listFuncId.add("UCfesa000003");
		listFuncId.add(currentBizFuncId);
		return listFuncId;
	}

	/**
	 * 由Struts框架ServletRequestAware接口获得HttpServletRequest后获得session、
	 * BizFunction相关信息 注：包含FEOSA_UI_INFO_MAP 公共查询资源定义
	 * 
	 * @see org.apache.struts2.interceptor.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)
	 * @param request
	 *            modify history: 2008/12/26 KevinChen Debug:initial
	 *            FEOSA_UI_COMMON_QUERY_LIST & FEOSA_UI_INFO_MAP if null.
	 */
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;

		// Get session data :UserInfo
	}

	/**
	 * Overriding method ,to get HttpServletResponse.
	 * 
	 * @see org.apache.struts2.interceptor.ServletResponseAware#setServletResponse(javax.servlet.http.HttpServletResponse)
	 * @param response
	 */
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	/**
	 * @return the response
	 */
	public javax.servlet.http.HttpServletResponse getResponse() {
		return response;
	}

	/**
	 * @return the request
	 */
	public javax.servlet.http.HttpServletRequest getRequest() {
		return request;
	}

	/**
	 * @return the servletContext
	 */
	public ServletContext getServletContext() {
		return servletContext;
	}

	/**
	 * 
	 * @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
	 * @param context
	 */
	public void setServletContext(ServletContext context) {
		this.servletContext = context;
	}

	/**
	 * this method should get those rules about this action from config (in DB
	 * or XML).
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#validate()
	 */

	public void validate() {

	}

	/**
	 * Default action method.
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 * @return action return value.
	 * @throws Exception
	 */

	public String execute() throws Exception {
		return super.execute();
	}

	/**
	 * Struts get locale method.
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#getLocale()
	 * @return Locale.
	 */

	public Locale getLocale() {
		return super.getLocale();
	}

	/**
	 * Struts get locale text.
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#getText(java.lang.String,
	 *      java.lang.String, java.util.List,
	 *      com.opensymphony.xwork2.util.ValueStack)
	 * @param key
	 * @param defaultValue
	 * @param args
	 * @param stack
	 * @return
	 */

	public String getText(String key, String defaultValue, List args,
			ValueStack stack) {
		return super.getText(key, defaultValue, args, stack);
	}

	/**
	 * This method use to get text for page render. This is a simple 'getText'
	 * rather than xWork.ActionSupport#getText.
	 * 
	 * @see PageConstants
	 * @param key
	 * @param defaultValue
	 * @param value
	 * @return
	 */
	public String getPageText(String key, String defaultValue, String value) {
		return null;
	}

}
